package org.grow.problem.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.grow.problem.dao.JYTJMapper;
import org.grow.problem.entity.JYTJ;
import org.grow.problem.entity.JYTJQueryCondition;
import org.grow.problem.entity.PagedResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xwg
 * @CreateDate: 2022/5/18
 */

@RestController
@RequestMapping("/problem/jytl")
public class JYTJController {

    @Autowired
    private JYTJMapper jytjMapper;

    @PostMapping("/insert")
    public JYTJ insert(@RequestBody JYTJ jytj) {
        int insert = jytjMapper.insert(jytj);
        return jytj;
    }

    @PostMapping("/query")
    public PagedResult<JYTJ> query(@RequestBody JYTJQueryCondition qc) {
        Page<JYTJ> page = new Page<>();
        IPage<JYTJ> page1 = jytjMapper.dynamicQuery(page, qc);
        return new PagedResult<>(page1.getTotal(), page.getRecords());
    }
}
